﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.MaterialDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
    navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.MaterialDetailViewModel">

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="4">
                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle" 
                        Style="{StaticResource TextBlockTitlePageStyle}"                   
                        Text="Thông tin Nguyên liệu"/>
            </Grid>

            <Grid 
                Background="Transparent"
                Grid.Row="2" Grid.Column="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!--Mã vật liệu-->
                <TextBlock 
                    Grid.Row="0" Grid.Column="0"
                    x:Name="lblcMaterialCode"
                    Style="{StaticResource TextBlockNormalStyle}"
                    >
                    <Run Text="{StaticResource MaterialCodeLabelText}" />
                    <Run Text=" *" Foreground="Red" />
                </TextBlock>
                <TextBox 
                    Grid.Row="0" Grid.Column="1"
                    x:Name="txtcMaterialCode"
                    IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                    Style="{StaticResource TextBoxNormalStyle}"
                    Text="{Binding Path=Material.MaterialCode, Mode=TwoWay, ValidatesOnDataErrors=True}"
                />

                <!--Tên vật liệu-->
                <TextBlock 
                    Grid.Row="1" Grid.Column="0"
                    x:Name="lblcMaterialName"
                    Style="{StaticResource TextBlockNormalStyle}"
                    >
                    <Run Text="{StaticResource MaterialNameLabelText}" />
                    <Run Text=" *" Foreground="Red" />
                </TextBlock>
                <TextBox 
                    Grid.Row="1" Grid.Column="1"
                    x:Name="txtcMaterialName"
                    IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                    Style="{StaticResource TextBoxNormalStyle}"
                    Text="{Binding Path=Material.MaterialName, Mode=TwoWay, ValidatesOnDataErrors=True}"
                />

                <!--Miêu tả vật liệu-->
                <TextBlock 
                    Grid.Row="2" Grid.Column="0"
                    x:Name="lblcDescription"
                    Style="{StaticResource TextBlockNormalStyle}"
                    Text="{StaticResource BriefDescriptionLabelText}"
                />
                <TextBox 
                    Grid.Row="2" Grid.Column="1" Grid.RowSpan="2" 
                    x:Name="txtcDescription"      
                    IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}"           
                    Style="{StaticResource TextBoxMultilineStyle}"
                    Text="{Binding Path=Material.Description, Mode=TwoWay}" />
            </Grid>

            <!--Message-->
            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
                />

            <!--Buttons-->
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
